package com.axis.sub;

import org.apache.commons.codec.digest.DigestUtils;

import java.util.Map;
import java.util.Random;

/**
 * Created by Administrator on 2015/7/20.
 */
public class SmsUtils {

    public static String sendMesForEms(String phoneNumber,String content){
        String requestStr=null;
        EmsServicesService sxtService=new EmsServicesServiceLocator();
        try {
            EmsServices client=sxtService.getemsServices();
            String pass= DigestUtils.md5Hex("whstx2015").toLowerCase();
            requestStr=client.sendSMS("16068","admin",pass,"","",content,phoneNumber,"");
        }catch (Exception e){
            e.printStackTrace();
        }
        return requestStr;
    }


    public static void main(String[] args) {
        String str=sendMesForEms("13018070647","您的订单{sn}已经支付成功,系统稍后进行出单，服务热线:｛mobile");
        System.out.println(str);
    }


    /**
     * 创建内容
     * */
    public static String createSMSContent(String content,Map<String,String> params){
        for(String key:params.keySet()){
            content=content.replace(key,params.get(key));
        }
        return content;
    }

    /** 生成数字验证码*/
    public static String getRandomNumber(int len){
        String content="";
        for(int i=0;i<len;i++){
            content=content+ new Random().nextInt(10);
        }
        return content;
    }

}
